home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / libgcc1.c < prev    next >
C/C++ Source or Header  |  1994-04-26  |  12KB  |  611 lines

  1. /* Subroutines needed by GCC output code on some machines.  */
  2. /* Compile this file with the Unix C compiler!  */
  3. /* Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
  4.  
  5. This file is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9.  
  10. In addition to the permissions in the GNU General Public License, the
  11. Free Software Foundation gives you unlimited permission to link the
  12. compiled version of this file with other programs, and to distribute
  13. those programs without any restriction coming from the use of this
  14. file.  (The General Public License restrictions do apply in other
  15. respects; for example, they cover modification of the file, and
  16. distribution when not linked into another program.)
  17.  
  18. This file is distributed in the hope that it will be useful, but
  19. WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  21. General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  26.  
  27. /* As a special exception, if you link this library with files
  28.    compiled with GCC to produce an executable, this does not cause
  29.    the resulting executable to be covered by the GNU General Public License.
  30.    This exception does not however invalidate any other reasons why
  31.    the executable file might be covered by the GNU General Public License.  */
  32.  
  33. #include "config.h"
  34. #ifdef SHLIB
  35. #include <libsys/shlib.h>
  36. #endif
  37.  
  38. /* Don't use `fancy_abort' here even if config.h says to use it.  */
  39. #ifdef abort
  40. #undef abort
  41. #endif
  42.  
  43. /* On some machines, cc is really GCC.  For these machines, we can't
  44.    expect these functions to be properly compiled unless GCC open codes
  45.    the operation (which is precisely when the function won't be used).
  46.    So allow tm.h to specify ways of accomplishing the operations
  47.    by defining the macros perform_*.
  48.  
  49.    On a machine where cc is some other compiler, there is usually no
  50.    reason to define perform_*.  The other compiler normally has other ways
  51.    of implementing all of these operations.
  52.  
  53.    In some cases a certain machine may come with GCC installed as cc
  54.    or may have some other compiler.  Then it may make sense for tm.h
  55.    to define perform_* only if __GNUC__ is defined.  */
  56.  
  57. #ifndef perform_mulsi3
  58. #define perform_mulsi3(a, b) return a * b
  59. #endif
  60.  
  61. #ifndef perform_divsi3
  62. #define perform_divsi3(a, b) return a / b
  63. #endif
  64.  
  65. #ifndef perform_udivsi3
  66. #define perform_udivsi3(a, b) return a / b
  67. #endif
  68.  
  69. #ifndef perform_modsi3
  70. #define perform_modsi3(a, b) return a % b
  71. #endif
  72.  
  73. #ifndef perform_umodsi3
  74. #define perform_umodsi3(a, b) return a % b
  75. #endif
  76.  
  77. #ifndef perform_lshrsi3
  78. #define perform_lshrsi3(a, b) return a >> b
  79. #endif
  80.  
  81. #ifndef perform_lshlsi3
  82. #define perform_lshlsi3(a, b) return a << b
  83. #endif
  84.  
  85. #ifndef perform_ashrsi3
  86. #define perform_ashrsi3(a, b) return a >> b
  87. #endif
  88.  
  89. #ifndef perform_ashlsi3
  90. #define perform_ashlsi3(a, b) return a << b
  91. #endif
  92.  
  93. #ifndef perform_adddf3
  94. #define perform_adddf3(a, b) return a + b
  95. #endif
  96.  
  97. #ifndef perform_subdf3
  98. #define perform_subdf3(a, b) return a - b
  99. #endif
  100.  
  101. #ifndef perform_muldf3
  102. #define perform_muldf3(a, b) return a * b
  103. #endif
  104.  
  105. #ifndef perform_divdf3
  106. #define perform_divdf3(a, b) return a / b
  107. #endif
  108.  
  109. #ifndef perform_addsf3
  110. #define perform_addsf3(a, b) return INTIFY (a + b)
  111. #endif
  112.  
  113. #ifndef perform_subsf3
  114. #define perform_subsf3(a, b) return INTIFY (a - b)
  115. #endif
  116.  
  117. #ifndef perform_mulsf3
  118. #define perform_mulsf3(a, b) return INTIFY (a * b)
  119. #endif
  120.  
  121. #ifndef perform_divsf3
  122. #define perform_divsf3(a, b) return INTIFY (a / b)
  123. #endif
  124.  
  125. #ifndef perform_negdf2
  126. #define perform_negdf2(a) return -a
  127. #endif
  128.  
  129. #ifndef perform_negsf2
  130. #define perform_negsf2(a) return INTIFY (-a)
  131. #endif
  132.  
  133. #ifndef perform_fixdfsi
  134. #define perform_fixdfsi(a) return (nongcc_SI_type) a;
  135. #endif
  136.  
  137. #ifndef perform_fixsfsi
  138. #define perform_fixsfsi(a) return (nongcc_SI_type) a
  139. #endif
  140.  
  141. #ifndef perform_floatsidf
  142. #define perform_floatsidf(a) return (double) a
  143. #endif
  144.  
  145. #ifndef perform_floatsisf
  146. #define perform_floatsisf(a)  return INTIFY ((float) a)
  147. #endif
  148.  
  149. #ifndef perform_extendsfdf2
  150. #define perform_extendsfdf2(a)  return a
  151. #endif
  152.  
  153. #ifndef perform_truncdfsf2
  154. #define perform_truncdfsf2(a)  return INTIFY (a)
  155. #endif
  156.  
  157. /* Note that eqdf2 returns a value for "true" that is == 0,
  158.    nedf2 returns a value for "true" that is != 0,
  159.    gtdf2 returns a value for "true" that is > 0,
  160.    and so on.  */
  161.  
  162. #ifndef perform_eqdf2
  163. #define perform_eqdf2(a, b) return !(a == b)
  164. #endif
  165.  
  166. #ifndef perform_nedf2
  167. #define perform_nedf2(a, b) return a != b
  168. #endif
  169.  
  170. #ifndef perform_gtdf2
  171. #define perform_gtdf2(a, b) return a > b
  172. #endif
  173.  
  174. #ifndef perform_gedf2
  175. #define perform_gedf2(a, b) return (a >= b) - 1
  176. #endif
  177.  
  178. #ifndef perform_ltdf2
  179. #define perform_ltdf2(a, b) return -(a < b)
  180. #endif
  181.  
  182. #ifndef perform_ledf2
  183. #define perform_ledf2(a, b) return 1 - (a <= b)
  184. #endif
  185.  
  186. #ifndef perform_eqsf2
  187. #define perform_eqsf2(a, b) return !(a == b)
  188. #endif
  189.  
  190. #ifndef perform_nesf2
  191. #define perform_nesf2(a, b) return a != b
  192. #endif
  193.  
  194. #ifndef perform_gtsf2
  195. #define perform_gtsf2(a, b) return a > b
  196. #endif
  197.  
  198. #ifndef perform_gesf2
  199. #define perform_gesf2(a, b) return (a >= b) - 1
  200. #endif
  201.  
  202. #ifndef perform_ltsf2
  203. #define perform_ltsf2(a, b) return -(a < b)
  204. #endif
  205.  
  206. #ifndef perform_lesf2
  207. #define perform_lesf2(a, b) return 1 - (a <= b);
  208. #endif
  209.  
  210. /* Define the C data type to use for an SImode value.  */
  211.  
  212. #ifndef nongcc_SI_type
  213. #define nongcc_SI_type long int
  214. #endif
  215.  
  216. /* Define the C data type to use for a value of word size */
  217. #ifndef nongcc_word_type
  218. #define nongcc_word_type nongcc_SI_type
  219. #endif
  220.  
  221. /* Define the type to be used for returning an SF mode value
  222.    and the method for turning a float into that type.
  223.    These definitions work for machines where an SF value is
  224.    returned in the same register as an int.  */
  225.  
  226. #ifndef FLOAT_VALUE_TYPE  
  227. #define FLOAT_VALUE_TYPE int
  228. #endif
  229.  
  230. #ifndef INTIFY
  231. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  232. #endif
  233.  
  234. #ifndef FLOATIFY
  235. #define FLOATIFY(INTVAL)  ((INTVAL).f)
  236. #endif
  237.  
  238. #ifndef FLOAT_ARG_TYPE
  239. #define FLOAT_ARG_TYPE union flt_or_int
  240. #endif
  241.  
  242. union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
  243.  
  244. union flt_or_int { int i; float f; };
  245.  
  246.  
  247. #ifdef L_mulsi3
  248. nongcc_SI_type
  249. __mulsi3 (a, b)
  250.      nongcc_SI_type a, b;
  251. {
  252.   perform_mulsi3 (a, b);
  253. }
  254. #endif
  255.  
  256. #ifdef L_udivsi3
  257. nongcc_SI_type
  258. __udivsi3 (a, b)
  259.      unsigned nongcc_SI_type a, b;
  260. {
  261.   perform_udivsi3 (a, b);
  262. }
  263. #endif
  264.  
  265. #ifdef L_divsi3
  266. nongcc_SI_type
  267. __divsi3 (a, b)
  268.      nongcc_SI_type a, b;
  269. {
  270.   perform_divsi3 (a, b);
  271. }
  272. #endif
  273.  
  274. #ifdef L_umodsi3
  275. nongcc_SI_type
  276. __umodsi3 (a, b)
  277.      unsigned nongcc_SI_type a, b;
  278. {
  279.   perform_umodsi3 (a, b);
  280. }
  281. #endif
  282.  
  283. #ifdef L_modsi3
  284. nongcc_SI_type
  285. __modsi3 (a, b)
  286.      nongcc_SI_type a, b;
  287. {
  288.   perform_modsi3 (a, b);
  289. }
  290. #endif
  291.  
  292. #ifdef L_lshrsi3
  293. nongcc_SI_type
  294. __lshrsi3 (a, b)
  295.      unsigned nongcc_SI_type a, b;
  296. {
  297.   perform_lshrsi3 (a, b);
  298. }
  299. #endif
  300.  
  301. #ifdef L_lshlsi3
  302. nongcc_SI_type
  303. __lshlsi3 (a, b)
  304.      unsigned nongcc_SI_type a, b;
  305. {
  306.   perform_lshlsi3 (a, b);
  307. }
  308. #endif
  309.  
  310. #ifdef L_ashrsi3
  311. nongcc_SI_type
  312. __ashrsi3 (a, b)
  313.      nongcc_SI_type a, b;
  314. {
  315.   perform_ashrsi3 (a, b);
  316. }
  317. #endif
  318.  
  319. #ifdef L_ashlsi3
  320. nongcc_SI_type
  321. __ashlsi3 (a, b)
  322.      nongcc_SI_type a, b;
  323. {
  324.   perform_ashlsi3 (a, b);
  325. }
  326. #endif
  327.  
  328. #ifdef L_divdf3
  329. double
  330. __divdf3 (a, b)
  331.      double a, b;
  332. {
  333.   perform_divdf3 (a, b);
  334. }
  335. #endif
  336.  
  337. #ifdef L_muldf3
  338. double
  339. __muldf3 (a, b)
  340.      double a, b;
  341. {
  342.   perform_muldf3 (a, b);
  343. }
  344. #endif
  345.  
  346. #ifdef L_negdf2
  347. double
  348. __negdf2 (a)
  349.      double a;
  350. {
  351.   perform_negdf2 (a);
  352. }
  353. #endif
  354.  
  355. #ifdef L_adddf3
  356. double
  357. __adddf3 (a, b)
  358.      double a, b;
  359. {
  360.   perform_adddf3 (a, b);
  361. }
  362. #endif
  363.  
  364. #ifdef L_subdf3
  365. double
  366. __subdf3 (a, b)
  367.      double a, b;
  368. {
  369.   perform_subdf3 (a, b);
  370. }
  371. #endif
  372.  
  373. /* Note that eqdf2 returns a value for "true" that is == 0,
  374.    nedf2 returns a value for "true" that is != 0,
  375.    gtdf2 returns a value for "true" that is > 0,
  376.    and so on.  */
  377.  
  378. #ifdef L_eqdf2
  379. nongcc_word_type
  380. __eqdf2 (a, b)
  381.      double a, b;
  382. {
  383.   /* Value == 0 iff a == b.  */
  384.   perform_eqdf2 (a, b);
  385. }
  386. #endif
  387.  
  388. #ifdef L_nedf2
  389. nongcc_word_type
  390. __nedf2 (a, b)
  391.      double a, b;
  392. {
  393.   /* Value != 0 iff a != b.  */
  394.   perform_nedf2 (a, b);
  395. }
  396. #endif
  397.  
  398. #ifdef L_gtdf2
  399. nongcc_word_type
  400. __gtdf2 (a, b)
  401.      double a, b;
  402. {
  403.   /* Value > 0 iff a > b.  */
  404.   perform_gtdf2 (a, b);
  405. }
  406. #endif
  407.  
  408. #ifdef L_gedf2
  409. nongcc_word_type
  410. __gedf2 (a, b)
  411.      double a, b;
  412. {
  413.   /* Value >= 0 iff a >= b.  */
  414.   perform_gedf2 (a, b);
  415. }
  416. #endif
  417.  
  418. #ifdef L_ltdf2
  419. nongcc_word_type
  420. __ltdf2 (a, b)
  421.      double a, b;
  422. {
  423.   /* Value < 0 iff a < b.  */
  424.   perform_ltdf2 (a, b);
  425. }
  426. #endif
  427.  
  428. #ifdef L_ledf2
  429. nongcc_word_type
  430. __ledf2 (a, b)
  431.      double a, b;
  432. {
  433.   /* Value <= 0 iff a <= b.  */
  434.   perform_ledf2 (a, b);
  435. }
  436. #endif
  437.  
  438. #ifdef L_fixdfsi
  439. nongcc_SI_type
  440. __fixdfsi (a)
  441.      double a;
  442. {
  443.   perform_fixdfsi (a);
  444. }
  445. #endif
  446.  
  447. #ifdef L_fixsfsi
  448. nongcc_SI_type
  449. __fixsfsi (a)
  450.      FLOAT_ARG_TYPE a;
  451. {
  452.   union flt_or_value intify;
  453.   perform_fixsfsi (FLOATIFY (a));
  454. }
  455. #endif
  456.  
  457. #ifdef L_floatsidf
  458. double
  459. __floatsidf (a)
  460.      nongcc_SI_type a;
  461. {
  462.   perform_floatsidf (a);
  463. }
  464. #endif
  465.  
  466. #ifdef L_floatsisf
  467. FLOAT_VALUE_TYPE
  468. __floatsisf (a)
  469.      nongcc_SI_type a;
  470. {
  471.   union flt_or_value intify;
  472.   perform_floatsisf (a);
  473. }
  474. #endif
  475.  
  476. #ifdef L_addsf3
  477. FLOAT_VALUE_TYPE
  478. __addsf3 (a, b)
  479.      FLOAT_ARG_TYPE a, b;
  480. {
  481.   union flt_or_value intify;
  482.   perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
  483. }
  484. #endif
  485.  
  486. #ifdef L_negsf2
  487. FLOAT_VALUE_TYPE
  488. __negsf2 (a)
  489.      FLOAT_ARG_TYPE a;
  490. {
  491.   union flt_or_value intify;
  492.   perform_negsf2 (FLOATIFY (a));
  493. }
  494. #endif
  495.  
  496. #ifdef L_subsf3
  497. FLOAT_VALUE_TYPE
  498. __subsf3 (a, b)
  499.      FLOAT_ARG_TYPE a, b;
  500. {
  501.   union flt_or_value intify;
  502.   perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
  503. }
  504. #endif
  505.  
  506. #ifdef L_eqsf2
  507. nongcc_word_type
  508. __eqsf2 (a, b)
  509.      FLOAT_ARG_TYPE a, b;
  510. {
  511.   union flt_or_int intify;
  512.   /* Value == 0 iff a == b.  */
  513.   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
  514. }
  515. #endif
  516.  
  517. #ifdef L_nesf2
  518. nongcc_word_type
  519. __nesf2 (a, b)
  520.      FLOAT_ARG_TYPE a, b;
  521. {
  522.   union flt_or_int intify;
  523.   /* Value != 0 iff a != b.  */
  524.   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
  525. }
  526. #endif
  527.  
  528. #ifdef L_gtsf2
  529. nongcc_word_type
  530. __gtsf2 (a, b)
  531.      FLOAT_ARG_TYPE a, b;
  532. {
  533.   union flt_or_int intify;
  534.   /* Value > 0 iff a > b.  */
  535.   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
  536. }
  537. #endif
  538.  
  539. #ifdef L_gesf2
  540. nongcc_word_type
  541. __gesf2 (a, b)
  542.      FLOAT_ARG_TYPE a, b;
  543. {
  544.   union flt_or_int intify;
  545.   /* Value >= 0 iff a >= b.  */
  546.   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
  547. }
  548. #endif
  549.  
  550. #ifdef L_ltsf2
  551. nongcc_word_type
  552. __ltsf2 (a, b)
  553.      FLOAT_ARG_TYPE a, b;
  554. {
  555.   union flt_or_int intify;
  556.   /* Value < 0 iff a < b.  */
  557.   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
  558. }
  559. #endif
  560.  
  561. #ifdef L_lesf2
  562. nongcc_word_type
  563. __lesf2 (a, b)
  564.      FLOAT_ARG_TYPE a, b;
  565. {
  566.   union flt_or_int intify;
  567.   /* Value <= 0 iff a <= b.  */
  568.   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
  569. }
  570. #endif
  571.  
  572. #ifdef L_mulsf3
  573. FLOAT_VALUE_TYPE
  574. __mulsf3 (a, b)
  575.      FLOAT_ARG_TYPE a, b;
  576. {
  577.   union flt_or_value intify;
  578.   perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
  579. }
  580. #endif
  581.  
  582. #ifdef L_divsf3
  583. FLOAT_VALUE_TYPE
  584. __divsf3 (a, b)
  585.      FLOAT_ARG_TYPE a, b;
  586. {
  587.   union flt_or_value intify;
  588.   perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
  589. }
  590. #endif
  591.  
  592. #ifdef L_truncdfsf2
  593. FLOAT_VALUE_TYPE
  594. __truncdfsf2 (a)
  595.      double a;
  596. {
  597.   union flt_or_value intify;
  598.   perform_truncdfsf2 (a);
  599. }
  600. #endif
  601.  
  602. #ifdef L_extendsfdf2
  603. double
  604. __extendsfdf2 (a)
  605.      FLOAT_ARG_TYPE a;
  606. {
  607.   union flt_or_value intify;
  608.   perform_extendsfdf2 (FLOATIFY (a));
  609. }
  610. #endif
  611.